package cn.app.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import cn.app.pojo.DevUser;
import cn.app.service.DevUserService;

@Controller
@RequestMapping("/dev")
public class DevUserController {
	@Resource
	private DevUserService devUserService;
	private Logger logger = Logger.getLogger(DevUserController.class);
	@RequestMapping("/login")
	public String goDevLogin(){
		return"devlogin";
	}
	@RequestMapping(value="/dologin",method=RequestMethod.POST)
	public String doLogin(String devCode,String devPassWord,HttpServletRequest request) throws Exception{
		DevUser devUser=devUserService.loginUser(devCode, devPassWord);
		logger.debug(devUser); 
		if (devUser!= null) {
			request.getSession().setAttribute("userSession",devUser);
			return " developer/main";
		}
		return"devlogin";
	}
}
